package org.example.controller.admin;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.example.entity.Shanpin;
import org.example.result.Result;
import org.example.service.WdzjService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/wdzj")
@Slf4j
@Api(tags = "商品足迹相关接口")
public class EmployeewdzjController {


    @Autowired
    WdzjService wdzjService;
    /**
     * 商品收藏修改
     *
     * @param
     * @return
     */
    @PutMapping("/xg")
    @ApiOperation(value = "商品足迹修改")
    public Result xg(@RequestParam("id") int id,
                     @RequestParam("username") String username) {
        log.info("商品足迹修改：{}", id);
        wdzjService.xg(id,username);
        return Result.success();

    }


    /**
     * 商品足迹商品查询
     *
     * @param
     * @return
     */
    @GetMapping("/shanpincx")
    @ApiOperation(value = "商品足迹商品查询")
    public Result<List<Shanpin>>  shanpincx(@RequestParam("username") String username) {
        log.info("商品足迹商品查询：{}");

        return Result.success( wdzjService.shanpincx(username));

    }


    /**
     * 足迹删除
     * @param
     * @return
     */
    @DeleteMapping("/sc")
    @ApiOperation(value = "足迹删除")
    public Result wdzjcx(@RequestParam( "id") int id,
                         @RequestParam( "username") String username) {
        log.info("足迹删除：{}", id);
        wdzjService.sc(id,username);
        return Result.success( );
    }


    /**
     * 足迹删除全部
     * @param
     * @return
     */
    @DeleteMapping("/scqb")
    @ApiOperation(value = "足迹删除全部")
    public Result wdzjplcx(@RequestParam( "username") String username) {
        log.info("足迹删除全部：{}", username);
        wdzjService.scqb(username);
        return Result.success( );
    }
}
